using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Unitins.Component.Repository.Sepsi;

public partial class _Default : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["Usuario"] != null)
            {
                DivOi.Visible = true;
                DivLogin.Visible = false;
                Usuario u = ((Usuario)Session["Usuario"]);
                lbNome.Text = u.Login;
            }
            else
            {
                DivOi.Visible = false;
                DivLogin.Visible = true;
            }
        }
    }
    protected void btnAut_Click(object sender, ImageClickEventArgs e)
    {
        Usuario u = UsuarioManager.Buscar(txtLogin.Text, UsuarioAttribute.Login);
        if (u != null && u.Senha.Equals(txtSenha.Text))
        {
            Session["Usuario"] = u;
            DivOi.Visible = true;
            DivLogin.Visible = false;
            u = ((Usuario)Session["Usuario"]);
            lbNome.Text = u.Login;
        }
        else
        {
            lbAviso.Text = "Login ou senha invalida";
            DivOi.Visible = false;
            DivLogin.Visible = true;
        }
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        DivOi.Visible = false;
        DivLogin.Visible = true;
        Session["Usuario"] = null;
        txtLogin.Text = "";
        txtSenha.Text = "";
        Response.Redirect("Default.aspx");
    }
}
